<template>
  <div>
    <div>
      您确定要交车吗？
      <FormPanel ref="formPanel" :list="formList" :cols="2" :formType="type" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle" />
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">取 消</el-button>
      <AjaxButton :click="saveDialog" type="primary" size="small">确 定</AjaxButton>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { alterTraceTime } from '@/api/repair/repairReception/giveCar';
export default {
  name: 'confirm',
  mixins: [dictionary],
  props: {
    type: {
      type: String,
      default: 'confirm'
    },
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      formList: this.createFormList()
    };
  },
  created() {},
  methods: {
    createFormList() {
      return [
        {
          type: 'SELECT',
          label: '回访时间',
          fieldName: 'traceTime',
          placeholder: '请输入',
          style: { width: '200px' },
          itemList: this.createDictList('8029'),
          rules: [{ required: true, message: '请填写回访时间', trigger: 'blur' }]
        }
      ];
    },
    formChangeHandle(val) {
      this.saveData = val;
    },
    async saveDialog() {
      console.log(this.rowData);
      this.$refs.formPanel.SUBMIT_FORM();
      if (this.saveData !== null) {
        let res = {};
        res = await alterTraceTime(this.rowData.RO_NO, this.saveData.traceTime, {});
        if (res.resultCode == 200) {
          this.$notify.success({ title: '提示信息', message: '交车成功!' });
        } else {
          this.$notify.error({ title: '提示信息', message: '交车失败!' });
        }
        this.closeDialog('refresh');
      }
    },
    closeDialog(param) {
      this.$emit('close', false, param);
    }
  }
};
</script>

<style lang="less" scoped></style>
